<?php defined('SYSPATH') or die('No direct script access.');

class Model_Siteuser extends ORM {
    
    protected $_table_name = 'users';
    
    /**
    * Правила валидации
    * 
    */
    public function rules() {
        return array(
            'email' => array(
                array('not_empty'),
                array('email'),
                array(array($this, 'uniqueness_check_email'))    
            ),
            'username' => array(),
            'password' => array(),
        );
    }
    
    public function uniqueness_check_email($email) {
        $temp = ORM::factory('siteuser', array('email' => $email));   
        if($temp -> loaded()) {
            return false;    
        } 
        else {
            return true;
        }
    }

} // End Siteuser
